"""
@Time    : 2025/7/23 15:26
@Author  : white.tie
@File    : tag.py
@Desc    : 带有标签的 FastAPI 应用
"""
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):
    name: str
    price: float

class ResponseMessage(BaseModel):
    message: str

class User(BaseModel):
    username: str
    email: str

@app.post("/items/",response_model=ResponseMessage,tags=["items"])
async def create_item(item: Item):
    return {"message":"Item received"}

@app.get("/items/",response_model=list[Item],tags=["items"])
async def read_items():
    return  [
        {"name": "Plumbus", "price": 3},
        {"name": "Portal Gun", "price": 9001},
    ]

@app.post("/users/", response_model=ResponseMessage, tags=["users"])
async def create_user(user: User):
    return {"message": "User received"}

if __name__ == '__main__':
    uvicorn.run(app,host="0.0.0.0",port=8060)